package team.southcat.wsyygh.oss.controller;


import team.southcat.wsyygh.oss.service.FileService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import team.southcat.wsyygh.common.result.Result;

@Api(tags = "文件接口")
@RestController
@RequestMapping("/api/oss/file")
public class FileApiController {
    @Autowired
    private FileService fileService;

    //上传文件到阿里云
    @ApiOperation("上传文件到阿里云")
    @PostMapping("/fileUpload")
    public Result fileUpload(MultipartFile file){  //通过MultipartFile可以得到上传文件
        //获取上传文件
        String url = fileService.upload(file);  //上传后得到路径
        System.out.println("上传成功：" + url);
        return Result.ok(url);
    }
    @GetMapping("/abc")
    public Result abc(){
        return Result.ok("abc");
    }
}
